<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>项目分组</title>
@include('common-css')
<style>
.input_box {
    width: 100%;
    height: 40px;
    margin-bottom: 15px;
    margin-top: 15px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.input_label {
    width: 120px;
    box-sizing: border-box;
}

.application-list {
    margin-top: 20px;
}

.phase-tag {
    color: #1890ff;
    border: 1px solid #91d5ff;
    border-radius: 3px;
    background: #e6f7ff;
    font-size: 12px;
    padding: 2px 3px;
}

.ant-table-tbody > tr > td, .ant-table-thead > tr > th {
    vertical-align: middle;
    line-height: 25px;
}

.action-table .ant-select {
    width: 120px;
}

.action-table .search-td {
    display: flex;
    justify-content: flex-start;
}

.action-table .ant-input {
    width: 178px;
}

.action-table .search-td .ant-btn {
    margin-left: 16px;
}

.my-pagination {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
}

.common_box {
    position: relative;
}

.search-box {
    position: absolute;
    right: 30px;
    top: 58px;
}

.search-box .ant-input {
    width: 300px;
}

.confirm-save-a {
    color: #52c41a;
}

.confirm-save-a:hover {
    color: #52c41a;
}

.cancel-save-a {
    color: #faad14;
}

.cancel-save-a:hover {
    color: #faad14;
}

.delete-btn-a {
    color: #f5222d
}

.login_input_container {
    position: relative;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 0 20px 20px;
}

.add-user-div {
    margin-bottom: 16px;
}

.ant-input-suffix {
    cursor: pointer;
}

.has-group-span {
    color: #f5222d;
}

.modal-action-table .ant-select {
    width: 120px;
}

.modal-action-table tr {
    height: 35px;
}

.modal-action-table .search-td {
    display: flex;
    justify-content: flex-start;
}

.modal-search-box {
    display: flex;
    width: 100%;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-search-box .ant-input {
    width: 300px;
}

.total-count-span {
    display: inline-block;
    text-align: center;
    height: 24px;
    width: 24px;
    background-color: #eee;
    margin-right: 8px;
    border-radius: 5px;
    color: #1890ff;
}

.delete-group-bottom-btn {
    margin-top: 16px;
}

.review-arrangement-table {
    width: 100%;
    text-align: left;
    border-collapse: collapse;
}

.review-arrangement-table > tr > th {
    vertical-align: middle;
    line-height: 20px;
    padding: 12px;
    font-weight: 500;
    border-bottom: 1px solid #e8e8e8;
    background: #fafafa;
}

.review-arrangement-table > tr > td {
    vertical-align: middle;
    line-height: 25px;
    padding: 12px;
    border-bottom: 1px solid #e8e8e8;
    font-size: 13px;
}

.review-arrangement-table > tr > td > div > table > tr > th {
    vertical-align: middle;
    padding: 8px;
    line-height: 18px;
    font-weight: 500;
    border: 1px solid #e8e8e8;
    background: #fafafa;
}

.review-arrangement-table > tr > td > div > table > tr > td {
    vertical-align: middle;
    padding: 8px;
    line-height: 15px;
    border: 1px solid #e8e8e8;
}

.my-modal-content-p {
    margin-top: 16px;
    margin-bottom: 8px;
}
</style>
</head>
<body>
<div id="app">
</div>
</body>
</html>
<script id="appTemplate" type="x-template">
<a-locale-provider :locale="antdLocale">
    <div class="container">

        @include('admin.header-tpl')

        <main>
            <div class="common_container">

                @include('admin.aside-tpl')

                <div class="common_content">
                    <div class="common_box">
                        <div class="add-user-div">
                            <a-button type="primary" @click="addGroupModelVisible = true">创建项目组</a-button>
                        </div>
                        <table class="action-table">
                            <tr>
                                <td width="100">所属奖项</td>
                                <td>
                                    <a-radio-group :value="filters.awardTypeId"
                                                   @change="handleAwardTypeFilterChange">
                                        <a-radio-button value="">不限</a-radio-button>
                                        <a-radio-button v-for="item in awardsInfo"
                                                        :value="item.id"
                                                        :key="item.id">@{{ item.name }}
                                        </a-radio-button>
                                    </a-radio-group>
                                </td>
                            </tr>
                        </table>
                        <div class="search-box">
                            <a-input v-model="filters.keyword" placeholder="按回车键搜索"
                                     @pressEnter="handleKeywordFilterChange">
                                <a-icon v-show="filters.keyword != ''" slot="suffix" type="close"
                                        style="color:#bfbfbf;font-size:13px"
                                        @click="resetSearch"/>
                            </a-input>
                        </div>
                        <a-table class="application-list"
                                 rowKey="id"
                                 :columns="groupListColumns"
                                 :dataSource="pageData"
                                 :pagination="false"
                        >
                            <template
                                    v-for="col in ['group_name']"
                                    :slot="col"
                                    slot-scope="text, record, index">
                                <div :key="col">
                                    <template v-if="record.editable">
                                        <a-textarea
                                                autosize
                                                style="margin: -5px 0; width:100%;"
                                                :value="text"
                                                @change="e => handleChange(e.target.value,record.id, col)"
                                        />
                                    </template>
                                    <template v-else>
                                        <span>@{{record.group_name}} <a-tag v-if="record.locked == 1" color="orange">已安排评审</a-tag></span>
                                    </template>
                                </div>
                            </template>
                            <span slot="award_type_id" slot-scope="text, record">
                                @{{ findAwardInfoById(record.award_type_id).name }}
                                </span>
                            <span slot="allocated" slot-scope="text, record">
                                    <template v-if="record.locked == 0">
                                    <a class="total-count-span"
                                       @click="showHasSelectedGroupInfo(record.id, record.group_name, record.award_type_id)">@{{ record.totalCount }}</a>
                                    <a @click="selectGroupProjects(record.id, record.group_name, record.award_type_id)">添加项目
                                    </a>
                                    </template>
                                    <template v-else>
                                        <a class="total-count-span"
                                           @click="showHasSelectedGroupInfo(record.id, record.group_name, record.award_type_id, 'readonly')">@{{ record.totalCount }}</a>
                                    </template>
                                </span>
                            <span slot="expert_group" slot-scope="text, record">
                                    <template v-if="record.locked == 0">
                                    <a class="total-count-span"
                                       @click="showHasSelectedExpertGroupsInAwardGroupInfo(record.id, record.group_name)">@{{ record.expertGroupTotalCount }}</a>
                                    <a @click="showAddExpertGroupGroupsModel(record.id, record.group_name)">添加评审小组
                                    </a>
                                    </template>
                                    <template v-else>
                                        <a class="total-count-span"
                                           @click="showHasSelectedExpertGroupsInAwardGroupInfo(record.id, record.group_name, 'readonly')">@{{ record.expertGroupTotalCount }}</a>
                                    </template>
                                </span>
                            <span slot="created_at" slot-scope="text, record">
                                    @{{ record.created_at | shortDateTime }}
                                </span>
                            <template slot="operations" slot-scope="text, record, index">
                                <div class='editable-row-operations'>
                                        <span v-if="record.editable">
                                            <a @click="save(record.id)">保存</a>
                                            <a @click="cancel(record.id)">取消</a>
                                        </span>
                                    <span v-else>
                                            <span v-if="record.locked == 0"><a
                                                        @click="allocateAwardToExpertGroup(record.id)">安排评审</a><br></span>
                                            <span v-else><a
                                                        @click="showReviewArrangement(record.id, record.group_name)">查看评审安排</a><br></span>
                                            <a @click="() => edit(record.id)">修改名称</a>
                                        <a-dropdown style="margin-left: 12px;" :trigger="['click']"
                                                    v-if="record.locked == 0">
                                            <a class="ant-dropdown-link" href="#">
                                                更多
                                                <a-icon type="down"/>
                                            </a>
                                            <a-menu slot="overlay">
                                                <a-menu-item key="delete-user">
                                                    <a-popconfirm title="确认删除该分组？"
                                                                  @confirm="handleDeleteGroup(record)"
                                                                  okText="是"
                                                                  cancelText="否">
                                                        <div class="delete-btn-a">删除</div>
                                                    </a-popconfirm>
                                                </a-menu-item>
                                            </a-menu>
                                        </a-dropdown>
                                        </span>
                                </div>
                            </template>
                        </a-table>
                        <div class="my-pagination">
                            <a-pagination :pageSize="pageSize"
                                          :current="currentPage" :total="totalCount"
                                          @change="handlePageChange"
                                          :showTotal="total => `共 ${total} 条`"
                            />
                        </div>
                    </div>
                </div>
            </div>
        </main>
        <a-modal :width="500" v-model="addGroupModelVisible" title="创建项目组"
                 @ok="handleAddGroup" @cancel="addGroupModelVisible = false">
            <div class="login_input_container">
                <div class="input_box">
                    <div class="input_label">所属奖项</div>
                    <div class="input_box">
                        <a-radio-group v-model="newGroupInfo.award_type_id"
                                       @change="">
                            <a-radio v-for="item in awardsInfo"
                                     :value="item.id"
                                     :key="item.id">@{{ item.name }}
                            </a-radio>
                        </a-radio-group>
                    </div>
                </div>
                <div class="input_box">
                    <div class="input_label">分组名称</div>
                    <div class="input_box">
                        <a-input placeholder="如: 科学技术进步奖-新能源" size="large" v-model="newGroupInfo.group_name"
                                 ref="usernameInput" autoFocus>
                        </a-input>
                    </div>
                </div>
            </div>
        </a-modal>
        <a-modal v-if="false" :width="732" v-model="selectGroupProjectsModelVisible" title="分配项目"
                 @ok="handleEditGroupSelectedProjects" @cancel="closeSelectGroupProjectsModel">
            <div class="login_input_container">
                <div class="input_box" style="margin-top:0">
                    <div class="input_label">分组名称: @{{ selectGroupProjectsInfo.group_name }}</div>
                </div>
                <template>
                    <a-transfer
                            :dataSource="selectGroupProjectsInfo.unallocated_projects"
                            showSearch
                            :titles="['可分配项目', '已分配项目']"
                            :filterOption="filterOption"
                            :listStyle="{width: '300px',height: '400px',}"
                            :targetKeys="selectGroupProjectsInfo.targetKeys"
                            @change="handleChangeGroupInfo"
                            :render="renderItem">
                        <span slot="notFoundContent">没数据</span>
                    </a-transfer>
                </template>
            </div>
        </a-modal>
        <a-modal :width="850" v-model="selectGroupProjectsModelVisible"
                 :title="'添加项目('+selectGroupProjectsInfo.group_name+')'">
            <div class="login_input_container">
                <table class="modal-action-table">
                    <tr>
                        <td width="100">分组筛选</td>
                        <td>
                            <a-radio-group size="small" :value="selectGroupProjectsInfo.filters.is_in_group"
                                           @change="handleModelIsInGroupFilterChange">
                                <a-radio-button value="">不限</a-radio-button>
                                <a-radio-button value="has">已分组</a-radio-button>
                                <a-radio-button value="not_has">未分组</a-radio-button>
                                </a-radio-button>
                            </a-radio-group>
                        </td>
                    </tr>
                </table>
                <div class="modal-search-box">
                        <span>
                            <span>
                                共 @{{selectGroupProjectsInfo.unallocated_projects.length}} 条
                            </span>
                            <span style="margin-left: 8px">
                                已选中 @{{selectGroupProjectsInfo.selectedKeys.length}} 条
                            </span>
                        </span>
                    <span>
                            <a-input size="small" v-model="selectGroupProjectsInfo.filters.keyword" placeholder="按回车键搜索"
                                     @pressEnter="handleModelKeywordFilterChange">
                                <a-icon v-show="selectGroupProjectsInfo.filters.keyword != ''" slot="suffix"
                                        type="close" style="color:#bfbfbf;font-size:13px"
                                        @click="resetModelSearch"/>
                            </a-input>
                        </span>
                </div>
                <a-table rowKey="id"
                         size="small"
                         :scroll="{ y: 500 }"
                         :columns="unallocatedProjectsListColumns"
                         :dataSource="selectGroupProjectsInfo.unallocated_projects"
                         :pagination="false"
                         :rowSelection="{selectedRowKeys: selectGroupProjectsInfo.selectedKeys, onChange: onSelectChange}"
                >
                        <span slot="award_name"
                              slot-scope="text, record">@{{ findAwardInfoById(record.award_id).name }}</span>
                    <span slot="project_name" slot-scope="text, record">@{{ record.project_name ? record.project_name : '-' }}</span>
                    <span slot="applicant" slot-scope="text, record">
                                @{{ record.applicant_name }}
                            </span>
                    <span slot="application_group_id" slot-scope="text, record">@{{ record.application_group_id ? "已分组" : "未分组"}}</span>
                </a-table>
            </div>
            <template slot="footer">
                <a-button key="back" @click="closeSelectGroupProjectsModel">取消</a-button>
                <a-button key="submit" type="primary" @click="handleImportAwardsToAwardGroup">
                    确认添加
                </a-button>
            </template>
        </a-modal>
        <a-modal :width="850" v-model="deleteGroupProjectsModelVisible" @cancel="closeDeleteGroupProjectsModel"
                 :title="'查看项目('+deleteGroupProjectsInfo.group_name+')'" :footer="null">
            <div class="login_input_container" v-if="deleteGroupProjectsInfo.show_type == 'edit'">
                <div class="modal-search-box">
                        <span>
                            <span>
                                共 @{{deleteGroupProjectsInfo.allocated_projects.length}} 条
                            </span>
                            <span style="margin-left: 8px">
                                已选中 @{{deleteGroupProjectsInfo.selectedKeys.length}} 条
                            </span>
                        </span>
                    <span>
                            <a-input size="small" v-model="deleteGroupProjectsInfo.filters.keyword" placeholder="按回车键搜索"
                                     @pressEnter="handleDeleteModelKeywordFilterChange">
                                <a-icon v-show="deleteGroupProjectsInfo.filters.keyword != ''" slot="suffix"
                                        type="close" style="color:#bfbfbf;font-size:13px"
                                        @click="resetDeleteModelSearch"/>
                            </a-input>
                        </span>
                </div>
                <a-table rowKey="id"
                         size="small"
                         :scroll="{ y: 500 }"
                         :columns="allocatedProjectsListColumns"
                         :dataSource="deleteGroupProjectsInfo.allocated_projects"
                         :pagination="false"
                         :rowSelection="{selectedRowKeys: deleteGroupProjectsInfo.selectedKeys, onChange: deleteModelOnSelectChange}"
                >
                        <span slot="award_name"
                              slot-scope="text, record">@{{ findAwardInfoById(record.award_id).name }}</span>
                    <span slot="project_name" slot-scope="text, record">@{{ record.project_name ? record.project_name : '-' }}</span>
                    <span slot="applicant" slot-scope="text, record">
                                @{{ record.applicant_name }}
                            </span>
                </a-table>
                <div class="delete-group-bottom-btn">
                    <a-button key="submit" @click="handleDeleteAwardsInGroup"
                              :disabled="deleteGroupProjectsInfo.selectedKeys.length < 1">
                        移出项目组
                    </a-button>
                </div>
            </div>
            <div class="login_input_container" v-else>
                <div class="modal-search-box">
                        <span>
                            <span>
                                共 @{{deleteGroupProjectsInfo.allocated_projects.length}} 条
                            </span>
                        </span>
                    <span>
                            <a-input size="small" v-model="deleteGroupProjectsInfo.filters.keyword" placeholder="按回车键搜索"
                                     @pressEnter="handleDeleteModelKeywordFilterChange">
                                <a-icon v-show="deleteGroupProjectsInfo.filters.keyword != ''" slot="suffix"
                                        type="close" style="color:#bfbfbf;font-size:13px"
                                        @click="resetDeleteModelSearch"/>
                            </a-input>
                        </span>
                </div>
                <a-table rowKey="id"
                         size="small"
                         :scroll="{ y: 500 }"
                         :columns="allocatedProjectsListColumns"
                         :dataSource="deleteGroupProjectsInfo.allocated_projects"
                         :pagination="false"
                >
                        <span slot="award_name"
                              slot-scope="text, record">@{{ findAwardInfoById(record.award_id).name }}</span>
                    <span slot="project_name" slot-scope="text, record">@{{ record.project_name ? record.project_name : '-' }}</span>
                    <span slot="applicant" slot-scope="text, record">
                                @{{ record.applicant_name }}
                            </span>
                </a-table>
            </div>
        </a-modal>

        <a-modal :width="800" v-model="selectExpertGroupsModelVisible"
                 :title="'添加评审小组('+selectExpertGroupsInfo.group_name+')'">
            <div class="login_input_container">
                <table class="modal-action-table">
                    <tr>
                        <td width="100">分组筛选</td>
                        <td>
                            <a-radio-group size="small" :value="selectExpertGroupsInfo.filters.is_in_group"
                                           @change="handleAddExpertGroupModelIsInGroupFilterChange">
                                <a-radio-button value="">不限</a-radio-button>
                                <a-radio-button value="has">已分组</a-radio-button>
                                <a-radio-button value="not_has">未分组</a-radio-button>
                                </a-radio-button>
                            </a-radio-group>
                        </td>
                    </tr>
                </table>
                <div class="modal-search-box">
                        <span>
                            <span>
                                共 @{{selectExpertGroupsInfo.unallocated_projects.length}} 条
                            </span>
                            <span style="margin-left: 8px">
                                已选中 @{{selectExpertGroupsInfo.selectedKeys.length}} 条
                            </span>
                        </span>
                    <span>
                            <a-input size="small" v-model="selectExpertGroupsInfo.filters.keyword" placeholder="按回车键搜索"
                                     @pressEnter="handleAddExpertGroupModelKeywordFilterChange">
                                <a-icon v-show="selectExpertGroupsInfo.filters.keyword != ''" slot="suffix"
                                        type="close" style="color:#bfbfbf;font-size:13px"
                                        @click="resetAddExpertGroupModelSearch"/>
                            </a-input>
                        </span>
                </div>
                <a-table rowKey="id"
                         size="small"
                         :scroll="{ y: 500 }"
                         :columns="unallocatedExpertGroupsListColumns"
                         :dataSource="selectExpertGroupsInfo.unallocated_projects"
                         :pagination="false"
                         :rowSelection="{selectedRowKeys: selectExpertGroupsInfo.selectedKeys, onChange: addExpertGroupModelSelectChange}"
                >
                    {{--                        <span slot="award_group_id" slot-scope="text, record">@{{ record.award_group_id ? "已分组" : "未分组"}}</span>--}}
                </a-table>
            </div>
            <template slot="footer">
                <a-button key="back" @click="closeAddExpertGroupsModel">取消</a-button>
                <a-button key="submit" type="primary" @click="handleImportExpertGroupsToAwardGroup">
                    确认添加
                </a-button>
            </template>
        </a-modal>
        <a-modal :width="600" v-model="deleteExpertGroupsModelVisible"
                 @cancel="closeDeleteExpertGroupsInAwardGroupModel"
                 :title="'查看评审小组('+deleteExpertGroupsInfo.group_name+')'" :footer="null">
            <div class="login_input_container" v-if="deleteExpertGroupsInfo.show_type == 'edit'">
                <div class="modal-search-box">
                        <span>
                            <span>
                                共 @{{deleteExpertGroupsInfo.allocated_projects.length}} 条
                            </span>
                            <span style="margin-left: 8px">
                                已选中 @{{deleteExpertGroupsInfo.selectedKeys.length}} 条
                            </span>
                        </span>
                    <span>
                            <a-input size="small" v-model="deleteExpertGroupsInfo.filters.keyword" placeholder="按回车键搜索"
                                     @pressEnter="handleDeleteExpertGroupsInAwardGroupModelKeywordFilterChange">
                                <a-icon v-show="deleteExpertGroupsInfo.filters.keyword != ''" slot="suffix"
                                        type="close" style="color:#bfbfbf;font-size:13px"
                                        @click="resetDeleteExpertGroupsInAwardGroupModelSearch"/>
                            </a-input>
                        </span>
                </div>
                <a-table rowKey="id"
                         size="small"
                         :scroll="{ y: 500 }"
                         :columns="allocatedExpertGroupsListColumns"
                         :dataSource="deleteExpertGroupsInfo.allocated_projects"
                         :pagination="false"
                         :rowSelection="{selectedRowKeys: deleteExpertGroupsInfo.selectedKeys, onChange: deleteExpertGroupsInAwardGroupModelOnSelectChange}"
                >
                </a-table>
                <div class="delete-group-bottom-btn">
                    <a-button key="submit" @click="handleDeleteExpertGroupsInAwardGroup"
                              :disabled="deleteExpertGroupsInfo.selectedKeys.length < 1">
                        移出项目组
                    </a-button>
                </div>
            </div>
            <div class="login_input_container" v-else>
                <div class="modal-search-box">
                        <span>
                            <span>
                                共 @{{deleteExpertGroupsInfo.allocated_projects.length}} 条
                            </span>
                        </span>
                    <span>
                            <a-input size="small" v-model="deleteExpertGroupsInfo.filters.keyword" placeholder="按回车键搜索"
                                     @pressEnter="handleDeleteExpertGroupsInAwardGroupModelKeywordFilterChange">
                                <a-icon v-show="deleteExpertGroupsInfo.filters.keyword != ''" slot="suffix"
                                        type="close" style="color:#bfbfbf;font-size:13px"
                                        @click="resetDeleteExpertGroupsInAwardGroupModelSearch"/>
                            </a-input>
                        </span>
                </div>
                <a-table rowKey="id"
                         size="small"
                         :scroll="{ y: 500 }"
                         :columns="allocatedExpertGroupsListColumns"
                         :dataSource="deleteExpertGroupsInfo.allocated_projects"
                         :pagination="false"
                >
                </a-table>
            </div>
        </a-modal>
        <a-modal :width="900" v-model="showReviewArrangementVisible"
                 :title="'查看评审安排('+reviewArrangementInfo.group_name+')'" :footer="null">
            <div class="login_input_container">
                <table class="review-arrangement-table">
                    <tr>
                        {{--                            <th>序号</th>--}}
                        <th width="200">评审小组</th>
                        <th>安排评审项目</th>
                    </tr>
                    <tr v-for="(item, index) in reviewArrangementInfo.info" :key="item.expert_group_id">
                        {{--                            <td width="100">@{{ index+1 }}</td>--}}
                        <td width="150">
                            <p>
                                名称：
                                <span style="font-weight: 500">@{{ item.expert_group_name }}</span>
                            </p>
                            <p>
                                组长：
                                <span style="font-weight: 500">@{{ item.expert_group_leader_name }}</span>
                            </p>
                            <p>
                                专家：
                                <span>@{{ item.expertsInfo.length }}</span>
                            </p>
                            <p>
                                项目：
                                <span>@{{ item.awardsInfo.length }}</span>
                            </p>
                            <table style="width:100%" v-if="false">
                                <tr>
                                    <th>姓名</th>
                                    <th>工作单位</th>
                                </tr>
                                <tr v-for="(expert, expertIndex) in item.expertsInfo">
                                    <td width="100">@{{ expert.name }}</td>
                                    <td width="200">@{{ expert.work_org_name }}</td>
                                </tr>
                            </table>
                        </td>
                        <td width="600">
                            <div style="max-height: 300px;overflow-y:auto">
                                <table style="width:100%">
                                    <tr>
                                        <th>项目名称</th>
                                        <th>申报者</th>
                                    </tr>
                                    <tr v-for="(award, projectIndex) in item.awardsInfo">
                                        <td width="300">@{{ award.project_name }}</td>
                                        <td width="300">@{{ award.applicant_name }}</td>
                                    </tr>
                                </table>
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
        </a-modal>
    </div>
</a-locale-provider>
</script>

@include('common-js')

@include('admin.header-js')
@include('admin.aside-js')

<script>
var awardsInfo = {!! json_encode(array_values(config('vars.awards')), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) !!};

const groupListColumns = [
    {
        width: 80,
        title: '序号',
        dataIndex: 'num'
    }, {
        width: 150,
        title: '名称',
        dataIndex: 'group_name',
        scopedSlots: {
            customRender: 'group_name'
        }
    }, {
        width: 100,
        title: '所属奖项',
        dataIndex: 'award_type_id',
        scopedSlots: {
            customRender: 'award_type_id'
        }
    }, {
        width: 120,
        title: '组内项目',
        dataIndex: 'allocated',
        scopedSlots: {
            customRender: 'allocated'
        }
    }, {
        width: 120,
        title: '评审小组',
        dataIndex: 'expert_group',
        scopedSlots: {
            customRender: 'expert_group'
        }
    }, {
        width: 120,
        title: '创建时间',
        dataIndex: 'created_at',
        scopedSlots: {
            customRender: 'created_at'
        }
    }, {
        width: 160,
        title: '操作',
        dataIndex: 'operations',
        scopedSlots: {
            customRender: 'operations'
        }
    }];

const unallocatedProjectsListColumns = [
    {
        width: 100,
        title: '序号',
        dataIndex: 'num'
    }, {
        width: 100,
        title: '奖项类型',
        dataIndex: 'award_name',
        scopedSlots: {
            customRender: 'award_name'
        }
    }, {
        width: 160,
        title: '项目名称',
        dataIndex: 'project_name',
        scopedSlots: {
            customRender: 'project_name'
        }
    }, {
        width: 180,
        title: '申报者',
        dataIndex: 'applicant',
        scopedSlots: {
            customRender: 'applicant'
        }
    },
    {
        width: 100,
        title: '是否已分组',
        dataIndex: 'application_group_id',
        scopedSlots: {
            customRender: 'application_group_id'
        }
    }
];

const allocatedProjectsListColumns = [
    {
        width: 100,
        title: '序号',
        dataIndex: 'num'
    }, {
        width: 100,
        title: '奖项类型',
        dataIndex: 'award_name',
        scopedSlots: {
            customRender: 'award_name'
        }
    }, {
        width: 180,
        title: '项目名称',
        dataIndex: 'project_name',
        scopedSlots: {
            customRender: 'project_name'
        }
    }, {
        width: 150,
        title: '申报者',
        dataIndex: 'applicant',
        scopedSlots: {
            customRender: 'applicant'
        }
    }
];

const unallocatedExpertGroupsListColumns = [
    {
        width: 100,
        title: '序号',
        dataIndex: 'num'
    }, {
        width: 250,
        title: '小组名称',
        dataIndex: 'group_name',
        scopedSlots: {
            customRender: 'group_name'
        }
    },
    {
        width: 100,
        title: '组长',
        dataIndex: 'leader_name',
        scopedSlots: {
            customRender: 'leader_name'
        }
    }
];

const allocatedExpertGroupsListColumns = [
    {
        width: 200,
        title: '序号',
        dataIndex: 'num'
    }, {
        width: 300,
        title: '小组名称',
        dataIndex: 'group_name',
        scopedSlots: {
            customRender: 'group_name'
        }
    }, {
        width: 100,
        title: '组长',
        dataIndex: 'leader_name',
        scopedSlots: {
            customRender: 'leader_name'
        }
    }
];

function processGroupsData(pageData, page) {
    var n = (page - 1) * 10 + 1
    pageData.forEach(item => {
        item.num = n
        n += 1
    })
    return pageData
}

function processDataAddNum(data) {
    var n = 1
    data.forEach(item => {
        item.num = n
        n += 1
    })
    return data
}

Vue.prototype.$axios = axios
var app = new Vue({
    el: '#app',
    template: '#appTemplate',
    data: {
        awardsInfo: awardsInfo,
        isSending: false,
        addGroupModelVisible: false,
        newGroupInfo: {
            group_name: '',
            award_type_id: 1
        },
        groupListColumns: groupListColumns,
        cacheData: [],
        currentPage: 1,
        pageSize: 10,
        pageData: [],
        totalCount: 0,
        filters: {
            sortBy: '',
            awardTypeId: '',
            keyword: ''
        },
        unallocatedProjectsListColumns: unallocatedProjectsListColumns,
        selectGroupProjectsModelVisible: false,
        selectGroupProjectsInfo: {
            filters: {
                keyword: '',
                is_in_group: ''
            },
            group_id: '',
            group_name: '',
            award_type_id: '',
            unallocated_projects: [],
            selectedKeys: [],
            targetKeys: [],
        },
        allocatedProjectsListColumns: allocatedProjectsListColumns,
        deleteGroupProjectsModelVisible: false,
        deleteGroupProjectsInfo: {
            filters: {
                keyword: '',
            },
            group_id: '',
            group_name: '',
            award_type_id: '',
            allocated_projects: [],
            selectedKeys: [],
            targetKeys: [],
            show_type: 'edit'
        },
        unallocatedExpertGroupsListColumns: unallocatedExpertGroupsListColumns,
        selectExpertGroupsModelVisible: false,
        selectExpertGroupsInfo: {
            filters: {
                keyword: '',
                is_in_group: ''
            },
            group_id: '',
            group_name: '',
            unallocated_projects: [],
            selectedKeys: [],
            targetKeys: [],
            leader_expert_id: ''
        },
        allocatedExpertGroupsListColumns: allocatedExpertGroupsListColumns,
        deleteExpertGroupsModelVisible: false,
        deleteExpertGroupsInfo: {
            filters: {
                keyword: '',
            },
            group_id: '',
            group_name: '',
            allocated_projects: [],
            selectedKeys: [],
            targetKeys: [],
            leader_expert_id: '',
            show_type: 'edit'
        },
        showReviewArrangementVisible: false,
        reviewArrangementInfo: {
            group_id: '',
            group_name: '',
            info: []
        },
        asideSelectedKeys: ['专家初评-项目分组'],
        antdLocale: antd.locales.zh_CN,
        ...AdminHeader.data,
        ...AdminAside.data,
    },
    filters: {
        shortDateTime(value) {
            if (value) {
                return moment(value).format('Y/M/D H:mm')
            }
            return value
        }
    },
    computed: {
        hasSelected() {
            return this.selectGroupProjectsInfo.selectedKeys.length > 0
        }
    },
    mounted() {
        this.fetchData()
        this.reloadAsideData()
    },
    methods: {
        showReviewArrangement(awardGroupId, awardGroupName) {
            this.reviewArrangementInfo.group_id = awardGroupId
            this.reviewArrangementInfo.group_name = awardGroupName
            megLoading('正在读取', 0)
            axios.post("/api/award/get-award-group-review-arrangement-info", {
                award_group_id: this.reviewArrangementInfo.group_id,
            }).then(res => {
                megDestroy()
                if (res.data.ok) {
                    this.reviewArrangementInfo.info = res.data.info
                    this.showReviewArrangementVisible = true;
                } else {
                    megError(res.data.message)
                }
            })
        },
        allocateAwardToExpertGroup(awardGroupId) {
            let _this = this
            this.$confirm({
                title: '确认要安排评审吗？',
                content:
                    {
                        tag: 'div',
                        data: {
                            class: 'test'
                        },
                        children: [
                            {
                                tag: 'p',
                                data: {
                                    class: 'my-modal-content-p'
                                },
                                text: '1. 该操作会将组内所有项目随机、平均分配给评审小组，每个评审小组分配的项目数量基本相同，评审小组内所有专家可看到分配给该小组的所有项目并打分。'
                            },
                            {
                                tag: 'p',
                                data: {
                                    class: 'my-modal-content-p'
                                },
                                text: '2. 分配完成后，该项目组以及相关评审小组的信息（组内项目、人员等）将锁定，不支持修改。'
                            }
                        ]
                    },
                ookText: '确认',
                cancelText: '取消',
                onOk() {
                    megLoading('正在安排评审...')
                    axios.post('/api/award/allocate-award-to-expert-group', {
                        award_group_id: awardGroupId
                    }).then(res => {
                        megDestroy()
                        if (res.data.ok) {
                            _this.$success({
                                title: '完成评审安排',
                                content: '所有项目已经随机平分到评审小组, 评审小组组长可以看到组内所有项目打分情况，非组长专家可以给分配到的项目打分',
                                okText: '知道了',
                                onOk() {
                                    _this.fetchData('not_edit')
                                },
                            })
                        } else {
                            megError(res.data.message)
                        }
                    })
                }
            })
        },
        //项目组添加评审小组弹窗
        resetAddExpertGroupModelSearch() {
            this.selectExpertGroupsInfo.filters.keyword = ''
            this.fetchAddExpertModelData()
        },
        handleAddExpertGroupModelIsInGroupFilterChange(e) {
            this.selectExpertGroupsInfo.filters.is_in_group = e.target.value
            this.fetchAddExpertModelData()
        },
        handleAddExpertGroupModelKeywordFilterChange(e) {
            this.selectExpertGroupsInfo.filters.keyword = e.target.value
            this.fetchAddExpertModelData()
        },
        fetchAddExpertModelData() {
            megLoading('正在读取', 0)
            axios.post("/api/award/get-award-group-add-expert-group-info", {
                award_group_id: this.selectExpertGroupsInfo.group_id,
                filters: this.selectExpertGroupsInfo.filters
            }).then(res => {
                megDestroy()
                if (res.data.ok) {
                    this.selectExpertGroupsInfo.unallocated_projects = processDataAddNum(res.data.unAllocatedExpertGroups)
                    this.selectExpertGroupsModelVisible = true;
                } else {
                    megError(res.data.message)
                }
            })
        },
        addExpertGroupModelSelectChange(selectedRowKeys) {
            this.selectExpertGroupsInfo.selectedKeys = selectedRowKeys
        },
        closeAddExpertGroupsModel() {
            this.selectExpertGroupsInfo.unallocated_projects = []
            this.selectExpertGroupsInfo.selectedKeys = []
            this.selectExpertGroupsModelVisible = false;
        },
        handleImportExpertGroupsToAwardGroup() {
            if (this.selectExpertGroupsInfo.selectedKeys.length < 1) {
                megWarn('请至少选择一个评审小组', 1)
                return false
            }
            megLoading('正在提交', 0)
            let selectExpertGroupsInfo = this.selectExpertGroupsInfo
            let relationsArr = this.getTargetAwardAndExpertGroupRelationsInfo(selectExpertGroupsInfo.selectedKeys, selectExpertGroupsInfo.group_id)
            axios.post("/api/award/import-expert-groups-to-award-group", {
                award_group_id: selectExpertGroupsInfo.group_id,
                new_relations: JSON.stringify(relationsArr)
            }).then(res => {
                megDestroy()
                if (res.data.ok) {
                    megSuccess('添加成功', 1)
                    this.selectExpertGroupsInfo.unallocated_projects = []
                    this.selectExpertGroupsInfo.selectedKeys = []
                    this.selectExpertGroupsModelVisible = false;
                    this.fetchData('is_import')
                } else {
                    megError(res.data.message)
                }
            })
        },
        getTargetAwardAndExpertGroupRelationsInfo(data, group_id) {
            let arr = []
            data.forEach(function (item) {
                arr.push({expert_group_id: parseInt(item), award_group_id: group_id})
            })
            console.log(arr)
            return arr
        },
        showAddExpertGroupGroupsModel(group_id, group_name) {
            this.selectExpertGroupsInfo.group_name = group_name
            this.selectExpertGroupsInfo.group_id = group_id
            this.fetchAddExpertModelData()
        },
        //查看项目组已添加评审小组弹窗
        deleteExpertGroupsInAwardGroupModelOnSelectChange(selectedRowKeys) {
            this.deleteExpertGroupsInfo.selectedKeys = selectedRowKeys
        },
        closeDeleteExpertGroupsInAwardGroupModel() {
            this.deleteExpertGroupsInfo.allocated_projects = []
            this.deleteExpertGroupsInfo.selectedKeys = []
            this.deleteExpertGroupsInfo.show_type = 'edit'
            this.deleteExpertGroupsModelVisible = false;
        },
        handleDeleteExpertGroupsInAwardGroup() {
            if (this.deleteExpertGroupsInfo.selectedKeys.length < 1) {
                antd.message.warn('请至少选择一个评审小组', 1)
                return false
            }
            let _this = this
            this.$confirm({
                title: '操作确认',
                content: '确认将所选评审小组移出该项目组吗？',
                okType: 'danger',
                maskClosable: true,
                onOk() {
                    antd.message.loading('正在操作', 0)
                    let deleteExpertGroupsInfo = _this.deleteExpertGroupsInfo
                    axios.post("/api/award/delete-expert-groups-in-award-group", {
                        award_group_id: deleteExpertGroupsInfo.group_id,
                        delete_expert_group_ids: JSON.stringify(deleteExpertGroupsInfo.selectedKeys)
                    }).then(res => {
                        antd.message.destroy()
                        if (res.data.ok) {
                            _this.$message.success('操作成功', 1)
                            _this.deleteExpertGroupsInfo.unallocated_projects = []
                            _this.deleteExpertGroupsInfo.selectedKeys = []
                            _this.deleteExpertGroupsModelVisible = false;
                            _this.fetchData('is_import')
                        } else {
                            _this.$message.error(res.data.message)
                        }
                    })
                },
                onCancel() {
                    return false
                },
            });
        },
        showHasSelectedExpertGroupsInAwardGroupInfo(group_id, group_name, show_type = 'edit') {
            this.deleteExpertGroupsInfo.group_name = group_name
            this.deleteExpertGroupsInfo.group_id = group_id
            this.deleteExpertGroupsInfo.show_type = show_type
            this.fetchDeleteExpertGroupsInAwardGroupModelData()
        },
        resetDeleteExpertGroupsInAwardGroupModelSearch() {
            this.deleteExpertGroupsInfo.filters.keyword = ''
            this.fetchDeleteExpertGroupsInAwardGroupModelData()
        },
        handleDeleteExpertGroupsInAwardGroupModelKeywordFilterChange(e) {
            this.deleteExpertGroupsInfo.filters.keyword = e.target.value
            this.fetchDeleteExpertGroupsInAwardGroupModelData()
        },
        fetchDeleteExpertGroupsInAwardGroupModelData() {
            antd.message.loading('正在读取', 0)
            axios.post("/api/award/get-selected-expert-group-in-award-info", {
                group_id: this.deleteExpertGroupsInfo.group_id,
                filters: this.deleteExpertGroupsInfo.filters
            }).then(res => {
                antd.message.destroy()
                if (res.data.ok) {
                    this.deleteExpertGroupsInfo.allocated_projects = processDataAddNum(res.data.allocatedExpertGroups)
                    this.deleteExpertGroupsModelVisible = true;
                } else {
                    this.$message.error(res.data.message)
                }
            })
        },
        //查看项目分组弹窗
        deleteModelOnSelectChange(selectedRowKeys) {
            this.deleteGroupProjectsInfo.selectedKeys = selectedRowKeys
        },
        handleDeleteAwardsInGroup() {
            if (this.deleteGroupProjectsInfo.selectedKeys.length < 1) {
                antd.message.warn('请至少选择一个项目', 1)
                return false
            }
            let _this = this
            this.$confirm({
                title: '操作确认',
                content: '确认将所选项目移出该项目组吗？',
                okType: 'danger',
                maskClosable: true,
                onOk() {
                    antd.message.loading('正在操作', 0)
                    let deleteGroupProjectsInfo = _this.deleteGroupProjectsInfo
                    axios.post("/api/award/delete-awards-in-award-group", {
                        group_id: deleteGroupProjectsInfo.group_id,
                        delete_award_ids: JSON.stringify(deleteGroupProjectsInfo.selectedKeys)
                    }).then(res => {
                        antd.message.destroy()
                        console.log(res)
                        if (res.data.ok) {
                            _this.$message.success('操作成功', 1)
                            _this.deleteGroupProjectsInfo.unallocated_projects = []
                            _this.deleteGroupProjectsInfo.selectedKeys = []
                            _this.deleteGroupProjectsModelVisible = false;
                            _this.fetchData('is_import')
                        } else {
                            _this.$message.error(res.data.message)
                        }
                    })
                },
                onCancel() {
                    return false
                },
            });
        },
        showHasSelectedGroupInfo(group_id, group_name, award_type_id, show_type = 'edit') {
            this.deleteGroupProjectsInfo.group_name = group_name
            this.deleteGroupProjectsInfo.group_id = group_id
            this.deleteGroupProjectsInfo.award_type_id = award_type_id
            this.deleteGroupProjectsInfo.show_type = show_type
            this.fetchDeleteModelData()
        },
        closeDeleteGroupProjectsModel() {
            this.deleteGroupProjectsInfo.allocated_projects = []
            this.deleteGroupProjectsInfo.selectedKeys = []
            this.deleteGroupProjectsInfo.show_type = 'edit'
            this.deleteGroupProjectsModelVisible = false;
        },
        resetDeleteModelSearch() {
            this.deleteGroupProjectsInfo.filters.keyword = ''
            this.fetchDeleteModelData()
        },
        handleDeleteModelKeywordFilterChange(e) {
            this.deleteGroupProjectsInfo.filters.keyword = e.target.value
            this.fetchDeleteModelData()
        },
        fetchDeleteModelData() {
            antd.message.loading('正在读取', 0)
            axios.post("/api/award/get-selected-group-award-info", {
                group_id: this.deleteGroupProjectsInfo.group_id,
                award_type_id: this.deleteGroupProjectsInfo.award_type_id,
                filters: this.deleteGroupProjectsInfo.filters
            }).then(res => {
                antd.message.destroy()
                console.log(res)
                if (res.data.ok) {
                    this.deleteGroupProjectsInfo.allocated_projects = processDataAddNum(res.data.allocatedProjects)
                    this.deleteGroupProjectsModelVisible = true;
                } else {
                    this.$message.error(res.data.message)
                }
            })
        },
        //添加项目弹窗
        resetModelSearch() {
            this.selectGroupProjectsInfo.filters.keyword = ''
            this.fetchModelData()
        },
        handleModelIsInGroupFilterChange(e) {
            this.selectGroupProjectsInfo.filters.is_in_group = e.target.value
            this.fetchModelData()
        },
        handleModelKeywordFilterChange(e) {
            this.selectGroupProjectsInfo.filters.keyword = e.target.value
            this.fetchModelData()
        },
        fetchModelData() {
            antd.message.loading('正在读取', 0)
            axios.post("/api/award/get-add-group-award-info", {
                group_id: this.selectGroupProjectsInfo.group_id,
                award_type_id: this.selectGroupProjectsInfo.award_type_id,
                filters: this.selectGroupProjectsInfo.filters
            }).then(res => {
                antd.message.destroy()
                console.log(res)
                if (res.data.ok) {
                    this.selectGroupProjectsInfo.unallocated_projects = processDataAddNum(res.data.unAllocatedProjects)
                    this.selectGroupProjectsModelVisible = true;
                } else {
                    this.$message.error(res.data.message)
                }
            })
        },
        onSelectChange(selectedRowKeys) {
            console.log('selectedRowKeys changed: ', selectedRowKeys);
            this.selectGroupProjectsInfo.selectedKeys = selectedRowKeys
        },
        closeSelectGroupProjectsModel() {
            this.selectGroupProjectsInfo.unallocated_projects = []
            this.selectGroupProjectsInfo.selectedKeys = []
            this.selectGroupProjectsModelVisible = false;
        },
        handleImportAwardsToAwardGroup() {
            if (this.selectGroupProjectsInfo.selectedKeys.length < 1) {
                antd.message.warn('请至少选择一个项目', 1)
                return false
            }
            antd.message.loading('正在提交', 0)
            let selectGroupProjectsInfo = this.selectGroupProjectsInfo
            let relationsArr = this.getTargetGroupRelationsInfo(selectGroupProjectsInfo.selectedKeys, selectGroupProjectsInfo.group_id)
            axios.post("/api/award/import-awards-to-award-group", {
                group_id: selectGroupProjectsInfo.group_id,
                new_relations: JSON.stringify(relationsArr)
            }).then(res => {
                antd.message.destroy()
                console.log(res)
                if (res.data.ok) {
                    this.$message.success('添加成功', 1)
                    this.selectGroupProjectsInfo.unallocated_projects = []
                    this.selectGroupProjectsInfo.selectedKeys = []
                    this.selectGroupProjectsModelVisible = false;
                    this.fetchData('is_import')
                } else {
                    this.$message.error(res.data.message)
                }
            })
        },
        selectGroupProjects(group_id, group_name, award_type_id) {
            this.selectGroupProjectsInfo.group_name = group_name
            this.selectGroupProjectsInfo.group_id = group_id
            this.selectGroupProjectsInfo.award_type_id = award_type_id
            this.fetchModelData()
        },
        //穿梭框
        renderItem(item) {
            let myGroupId = this.selectGroupProjectsInfo.group_id
            let customLabel = `${item.award_type}-${item.title}`
            if (item.application_group_id && item.application_group_id != myGroupId) {
                customLabel = `(已分组) ${item.award_type}-${item.title}`
            }
            return {
                label: customLabel,
                value: item.title
            };
        },
        filterOption(inputValue, option) {
            return option.project_name.indexOf(inputValue) > -1;
        },
        handleChangeGroupInfo(targetKeys, direction, moveKeys) {
            console.log(targetKeys, direction, moveKeys);
            this.selectGroupProjectsInfo.targetKeys = targetKeys
        },
        selectGroupProjectsOld(group_id, group_name) {
            antd.message.loading('正在读取', 0)
            axios.post("/api/award/get-select-group-award-info", {
                group_id,
            }).then(res => {
                antd.message.destroy()
                console.log(res)
                if (res.data.ok) {
                    this.selectGroupProjectsInfo.unallocated_projects = this.setKeys(res.data.unAllocatedProjects)
                    console.log('this.selectGroupProjectsInfo.unallocated_projects', this.selectGroupProjectsInfo.unallocated_projects)
                    this.selectGroupProjectsInfo.targetKeys = this.keyToString(res.data.allocatedProjectIds)
                    console.log('this.selectGroupProjectsInfo.targetKeys', this.selectGroupProjectsInfo.targetKeys)
                    this.selectGroupProjectsInfo.group_name = group_name
                    this.selectGroupProjectsInfo.group_id = group_id
                    this.selectGroupProjectsModelVisible = true;
                } else {
                    this.$message.error(res.data.message)
                }
            })
        },
        getTargetGroupRelationsInfo(data, group_id) {
            let arr = []
            data.forEach(function (item) {
                arr.push({application_id: parseInt(item), application_group_id: group_id})
            })
            console.log(arr)
            return arr
        },
        keyToString(data) {
            let targetKeys = []
            data.forEach(function (item) {
                targetKeys.push(item.toString())
            })
            console.log(targetKeys)
            return targetKeys
        },
        setKeys(data) {
            let that = this
            data.forEach(function (item) {
                item.key = item.id.toString()
                // item.hasGroup = item.application_group_id ? true : false
                item.award_type = that.findAwardInfoById(item.award_id).name
                item.title = item.project_name || '未命名'
            })
            return data
        },
        //创建分组
        handleAddGroup() {
            let {group_name, award_type_id} = this.newGroupInfo
            if (this.isSending) return
            if (!group_name) return this.$message.error("请填写分组名称")
            this.isSending = true
            this.$message.loading('正在提交...', 0)
            this.$axios.post("/api/award/create-award-group", {
                group_name,
                award_type_id
            }).then(res => {
                console.log(res);
                this.$message.destroy()
                this.isSending = false
                if (res.data.ok) {
                    this.$message.success('添加成功', 1)
                    history.go(0)
                } else {
                    this.$message.error(res.data.message)
                }
            })
        },
        resetSearch() {
            this.filters.keyword = ''
            this.fetchData()
        },
        handleAwardTypeFilterChange(e) {
            this.filters.awardTypeId = e.target.value
            this.fetchData()
        },
        handleKeywordFilterChange(e) {
            console.log('keyword', e.target.value)
            // this.currentPage = 1
            this.filters.keyword = e.target.value
            this.fetchData()
        },
        fetchData(type = 'is_edit') {
            if (type === 'is_edit') {
                antd.message.loading('正在读取', 0)
            }
            axios.get('/api/award/get-award-group-page-data', {
                params: {
                    page: this.currentPage,
                    pageSize: this.pageSize,
                    filters: this.filters
                }
            }).then(res => {
                console.log('res', res)
                antd.message.destroy()
                this.pageData = processGroupsData(res.data.data, res.data.current_page)
                this.cacheData = this.pageData.map(item => ({...item}))
                this.totalCount = res.data.total
                this.currentPage = res.data.current_page
            })
        },
        handleSortByChange(value) {
            this.sortBy = value;
            this.fetchData()
        },
        handlePageChange(currentPage) {
            console.log('handlePageChange', currentPage)
            this.currentPage = currentPage
            this.fetchData()
        },
        handleDeleteGroup(group) {
            let _this = this
            antd.message.loading('正在处理，请稍候', 0)
            axios.post('/api/award/delete-award-group', {
                group_id: group.id,
                type: 0
            }).then(res => {
                antd.message.destroy()
                console.log(res)
                var data = res.data
                if (data.ok) {
                    if (data.message) {
                        _this.$confirm({
                            title: data.message,
                            okType: 'danger',
                            onOk() {
                                axios.post('/api/award/delete-award-group', {
                                    group_id: group.id,
                                    type: 1
                                }).then(res => {
                                    antd.message.destroy()
                                    console.log(res)
                                    var data = res.data
                                    if (data.ok) {
                                        antd.message.success('删除成功', 0)
                                        _this.fetchData('is_delete')
                                    } else {
                                        antd.message.warn(data.message, 3)
                                    }
                                })
                            },
                            onCancel() {
                                return false
                            },
                        });
                    } else {
                        antd.message.success('删除成功', 0)
                        _this.fetchData('is_delete')
                    }
                } else {
                    antd.message.warn(data.message, 3)
                }
            })
        },
        updateGroupBasicInfo(id, target, newData) {
            antd.message.loading('正在处理，请稍候', 0)
            axios.post('/api/award/update-award-group-basic-info-by-id', {
                group_id: id,
                target
            }).then(res => {
                antd.message.destroy()
                console.log(res)
                var data = res.data
                if (data.ok) {
                    delete target.editable
                    this.pageData = newData
                    this.cacheData = newData.map(item => ({...item}))
                    antd.message.success('修改成功', 1)
                    // this.reloadData()
                } else {
                    antd.message.warn(data.message, 3)
                }
            })
        },
        handleChange(value, recordId, column) {
            console.log('rowData-change', value, recordId, column)
            const newData = [...this.pageData]
            const target = newData.filter(item => recordId === item.id)[0]
            if (target) {
                target[column] = value
                this.pageData = newData
            }
        },
        edit(recordId) {
            console.log('edit-id', recordId)
            let newData = [...this.pageData]
            let target = newData.filter(item => recordId === item.id)[0]
            console.log('edit-target', target)
            if (target) {
                target.editable = true
                this.pageData = newData
            }
        },
        save(recordId) {
            console.log('save-recordId', recordId)
            const newData = [...this.pageData]
            const target = newData.filter(item => recordId === item.id)[0]
            if (target) {
                if (!target.group_name) {
                    antd.message.warn('名称不能为空')
                    return false
                }
                this.updateGroupBasicInfo(recordId, target, newData)
            }
        },
        cancel(recordId) {
            const newData = [...this.pageData]
            const target = newData.filter(item => recordId === item.id)[0]
            if (target) {
                Object.assign(target, this.cacheData.filter(item => recordId === item.id)[0])
                delete target.editable
                this.pageData = newData
            }
        },
        findAwardInfoById(id) {
            return this.awardsInfo.filter(item => {
                return item.id == id
            })[0]
        },
        ...AdminHeader.methods,
        ...AdminAside.methods,
    }
})
</script>